#ifndef _PI_H_
#define _PI_H_
#include "apt32f102_ck801.h"

typedef struct
{
	double i32Q12_Kp_coef;
	double i32Q12_Ki_coef;
    double i32Q12_Kp;
    double i32Q12_Ki;
	double i32Q12_Kd;
    double i32Q27_OutMin;
    double i32Q27_OutMax;
		
} stc_pid_para_t;


/** position PI ***********************************************************/
typedef struct 
{
	char u8En;
	int i32Q15_Ref; //Input: reference  
	int i32Q15_Fbk; //Input: feedback
	double i32Q27_Output; //Output: control output
	int i32Q15_Err; //Data:error term	
//	int32_t i32Q24_Pout;  //Data: proportional term
	double i32Q27_Iout;  //Data: integral term 
	int i32Q27_FdFwd; //Option: feed-forward
	char u8IntegralLmtFlg;
	int i32Q15_LastErr;
	int i32Q15_LastErrInc;//上一次的温差
}stc_pi_t;

extern stc_pid_para_t pid_para_t;

void PI_Ctrl(stc_pi_t *pstc, stc_pid_para_t *stcPIParam,int grill_temperature,int temp_set);




#endif

